//
//  MusicChannelCollectionViewCell.m
//  YHYRealx
//
//  Created by yanghuiyan on 16/4/26.
//  Copyright © 2016年 yanghuiyan. All rights reserved.
//

#import "MusicChannelCollectionViewCell.h"

@implementation MusicChannelCollectionViewCell

- (void)dealloc {
    
    [_labelDetail release];
    [_imagePic release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor colorWithRed:0.00 green:0.20 blue:0.30 alpha:1.00];
        _labelDetail = [YHYBaseLabel new];
        _labelDetail.textAlignment = NSTextAlignmentCenter;
        _labelDetail.textColor = [UIColor colorWithRed:0.57 green:0.59 blue:0.62 alpha:1.00];
        _labelDetail.font = [UIFont systemFontOfSize:14];
        
        [self.contentView addSubview:_labelDetail];
        _imagePic = [UIImageView new];
        [self.contentView addSubview:_imagePic];
        
        
        [_labelDetail release];
        [_imagePic release];
        
        
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [_labelDetail mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self.contentView.mas_centerX);
        make.bottom.equalTo(self.contentView).offset(-10);
        make.top.equalTo(_imagePic.mas_bottom).offset(5);
        make.width.equalTo(@65);
        
    }];
    
    [_imagePic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.centerX.equalTo(self.contentView.mas_centerX);
        make.height.equalTo(@45);
        make.width.equalTo(@45);
        
    }];
}

- (void)setDetailModel:(MusicDetailDataModel *)detailModel {
    
    if (_detailModel != detailModel) {
        [_detailModel release];
        _detailModel = [detailModel retain];
    }
    
    [_imagePic sd_setImageWithURL:[NSURL URLWithString:detailModel.picUrl]];
    _labelDetail.text = detailModel.name;
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
